package com.hongyun.sdk.common;

import java.util.HashMap;
import java.util.Map;

public enum HongYunCommonStatus {


    unknown_order("30120001", "未知订单"),
    order_verified_success("30120002", "订单已核销"),
    order_no_verified("30120003", "订单无需核销"),
    order_no_exist("30111008", "订单信息不存在"),
    order_status_fail("30111009", "单不是交易成功状态，不能申请退款"),
    order_refunded_fail("30111010", "订单已经退单审核通过，不能再次申请退单"),
    order_verified_refunded_fail("30111014", "订单已核销，不能申请退单"),

    system_fail("50000", "系统错误"),
    param_fail("40002", "请求参数缺失"),
    sign_fail("40006", "签名验证失败"),
    search_order_fail("40501", "查询订单失败"),
    order_verified("40503", "订单已核销");


    private final String status;
    private final String info;

    HongYunCommonStatus(String status, String info) {
        this.status = status;
        this.info = info;
    }


    public static Map<String, String> toMap() {
        Map<String, String> map = new HashMap<String, String>();
        for (HongYunCommonStatus commonStatus : HongYunCommonStatus.values()) {
            map.put(commonStatus.getStatus(), commonStatus.getInfo());
        }
        return map;
    }

    public static String getInfoByStatus(Integer code) {
        String result = null;
        Map<String, String> multiMap = HongYunCommonStatus.toMap();
        for (Map.Entry<String, String> stringObjectEntry : multiMap.entrySet()) {
            if (stringObjectEntry.getKey().equals(code)) {
                result = stringObjectEntry.getValue();
            }
        }
        return result;
    }


    public String getStatus() {
        return status;
    }

    public String getInfo() {
        return info;
    }
}
